<?php
/**
 * Created by PhpStorm.
 * User: yanyan
 * Date: 16/8/3
 * Time: 10:01
 */

namespace home\Controller;
use Think\Controller;

class SysmsgController extends ApibaseController {
    /*
     * 日志功能
     * @date: 2016-8-3上午10:09:00
     * @editor: yanyan
     */
    public function showlogs(){
        /*参数初始化*/
        $page = I('get.page') ?: 1;
        $perpage = 10;$url = '';
        $getResList = M('ResEntity')->where(array('is_active'=>'1'))->select();
        $list = M('SysLogs');
        if(I('get.rid')){
            $list = $list->where(array('sys_editor'=>I('get.rid')));
            $url['rid'] = I('get.rid');
        }
        if(I('get.dotime')){
            $list = $list->where('add_at > '.strtotime(I('get.dotime')).' AND add_at < '.(strtotime(I('get.dotime'))+24*3600));
            $url['dotime'] = I('get.dotime');
        }

        $getObj = clone $list;
        $sysData = $list->order(array('sys_action_id'=>'desc'))->page($page,$perpage)->select();
        $this->assign('page',setPage($getObj->count(),$perpage,$page,'?'.http_build_query($url)));
        $this->assign('sysData',$sysData);
        $this->assign('getResList',$getResList);
        $this->display('sysmsg/logs');
    }
}